﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 字符串时间格式转换
{
    class Program
    {
        static void Main(string[] args)
        {
            string date = ToCharacter("2030年10月31日");
            Console.WriteLine(date);
            Console.ReadKey();
        }

        static string ToCharacter(string str)
        {
            char[] chars = str.ToCharArray();
            string output = "";
            for (int i = 0; i < 4; i++)
            {
                char t = chars[i];
                switch (t)
                {
                    case '0':
                        output += "零";
                        break;
                    case '1':
                        output += "一";
                        break;
                    case '2':
                        output += "二";
                        break;
                    case '3':
                        output += "三";
                        break;
                    case '4':
                        output += "四";
                        break;
                    case '5':
                        output += "五";
                        break;
                    case '6':
                        output += "六";
                        break;
                    case '7':
                        output += "七";
                        break;
                    case '8':
                        output += "八";
                        break;
                    case '9':
                        output += "九";
                        break;
                    default:
                        break;
                }
            }

            output += "年";

            for (int i = 5; i < chars.Length; i++)
            {
                char t = chars[i];

                if ('日' == chars[i] || '月' == chars[i])
                {
                    output += chars[i];
                    continue;
                }
                switch (t)
                {
                    case '0':
                        break;
                    case '1':
                        if('月' != chars[i+1] && '日' != chars[i+1])
                        {
                            output += "十";
                            break;
                        }
                        else
                        {
                            output += "一";
                            break;
                        }
                    case '2':
                        if ('月' != chars[i + 1] && '日' != chars[i + 1])
                        {
                            output += "二十";
                            break;
                        }
                        else
                        {
                            output += "二";
                            break;
                        }
                    case '3':
                        if ('月' != chars[i + 1] && '日' != chars[i + 1])
                        {
                            output += "三十";
                            break;
                        }
                        else
                        {
                            output += "三";
                            break;
                        }
                    case '4':
                        output += "四";
                        break;
                    case '5':
                        output += "五";
                        break;
                    case '6':
                        output += "六";
                        break;
                    case '7':
                        output += "七";
                        break;
                    case '8':
                        output += "八";
                        break;
                    case '9':
                        output += "九";
                        break;
                    default:
                        break;
                }
            }

            return output;
        }
    }
}
